package com.prs.crm.dao.sys.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.sys.PasswordSetDao;
import com.prs.crm.domain.sys.PasswordSet;

public class PasswordSetDaoImpl extends BaseDaoImpl<PasswordSet> implements PasswordSetDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<PasswordSet> getAllPasswordSet() {
		Criteria criteria=this.getSession().createCriteria(PasswordSet.class);
		return criteria.list();
	}

	@Override
	public PasswordSet getPasswordSet(final String code) {
		Criteria criteria=this.getSession().createCriteria(PasswordSet.class);
		criteria.add(Restrictions.eq("type", code));
		List result=criteria.list();
		if(result==null|| result.size()==0){
			return null;
		}
	 	return (PasswordSet) criteria.list().get(0);
	}

}
